﻿<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<#include "../util/TypeInfo.ftl">
<#assign entityName = pojo.shortName>
<#assign componentName = entityName?uncap_first>
<#assign homeName = componentName + "Home">
<#assign masterPageName = entityName + "List">
<#assign pageName = entityName>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">
	<h:form id="${componentName}" styleClass="edit">

        <rich:panel>
            <f:facet name="header">${label(entityName)}</f:facet>

            <#foreach property in pojo.allPropertiesIterator>
            	<#assign propertyIsId = property.equals(pojo.identifierProperty)>
            	<#if !propertyIsId>
            		<#include "editproperty.xhtml.ftl">
            	</#if>
            </#foreach>
            
            <div style="clear:both">
                <span class="required">*</span>
                Zorunlu alan
            </div>

        </rich:panel>

        <div style="clear: both" />
        
        <div class="actionButtons">
			<a:commandButton value="Kaydet" action="${'#'}{${homeName}.persist}" rendered="${'#'}{!${homeName}.managed}" reRender="${componentName}, ${componentName}Table"/> 
			<a:commandButton value="Güncelle" action="${'#'}{${homeName}.update}" rendered="${'#'}{${homeName}.managed}" reRender="${componentName}, ${componentName}Table"/> 
			<a:commandButton ajaxSingle="true" action="${'#'}{${homeName}.remove}" value="Sil" rendered="${'#'}{${homeName}.managed}" reRender="${componentName}, ${componentName}Table"/>
			<a:commandButton ajaxSingle="true" action="${'#'}{${homeName}.cancel}" value="Temizle" rendered="${'#'}{${homeName}.managed}" reRender="${componentName}"/>
        </div>
    </h:form>

    <h:form>
		<rich:dataTable id="${componentName}Table" var="${componentName}" value="${'#'}{${componentName}List.resultListWithPaging}"  rows="${'#'}{${componentName}List.maxResults}">
				  
			<rich:column width="60px">
				<f:facet name="header">Sil</f:facet>
				<a:commandLink value="Sil" action="${'#'}{${componentName}Home.remove(${componentName})}" reRender="${componentName}Table"/>  
			</rich:column>
			<rich:column width="60px">
				<f:facet name="header">Düzenle</f:facet>
				<a:commandLink value="Düzenle" action="${'#'}{${componentName}Home.sec(${componentName})}" reRender="${componentName}"/>  
			</rich:column>              
	<#foreach property in pojo.allPropertiesIterator>
	<#if !c2h.isCollection(property) && !isToOne(property) && property != pojo.versionProperty!>
	<#if pojo.isComponent(property)>
	<#foreach componentProperty in property.value.propertyIterator>
			<rich:column>
				<f:facet name="header">
					<ui:include src="layout/sort.xhtml">
						<ui:param name="entityList" value="${'#'}{${componentName}List}"/>
						<ui:param name="propertyLabel" value="${property.name} ${componentProperty.name}"/>
						<ui:param name="propertyPath" value="${componentName}.${property.name}.${componentProperty.name}"/>
						<ui:param name="tableId" value="${componentName}Table"/>
					</ui:include>
				</f:facet>
				<@outputValue property=componentProperty expression="${'#'}{${componentName}.${property.name}.${componentProperty.name}}" indent=12/>
			</rich:column>
	</#foreach>
	<#else>
			<rich:column>
				<f:facet name="header">
					<ui:include src="layout/sort.xhtml">
						<ui:param name="entityList" value="${'#'}{${componentName}List}"/>
						<ui:param name="propertyLabel" value="${property.name}"/>
						<ui:param name="propertyPath" value="${componentName}.${property.name}"/>
						<ui:param name="tableId" value="${componentName}Table"/>
					</ui:include>
				</f:facet>
				<@outputValue property=property expression="${'#'}{${componentName}.${property.name}}" indent=12/>
			</rich:column>
	</#if>
	</#if>
	<#if c2h.isOneToOne(property)>
	<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
	<#if parentPojo.isComponent(parentPojo.identifierProperty)>
			<rich:column>
				<f:facet name="header">
					<ui:include src="layout/sort.xhtml">
						<ui:param name="entityList" value="${'#'}{${componentName}List}"/>
						<ui:param name="propertyLabel" value="${property.name}"/>
						<ui:param name="propertyPath" value="${componentName}.${property.name}"/>
						<ui:param name="tableId" value="${componentName}Table"/>
					</ui:include>
				</f:facet>
				${pojo.generateOneToOneAnnotation(property, cfg)}---
				<@outputValue property=componentProperty expression="${'#'}{${componentName}.${property.name}.name}" indent=12/>
			</rich:column>
	<#else>
	<#foreach componentProperty in parentPojo.allPropertiesIterator>
	   <#if !c2h.isCollection(componentProperty) && !isToOne(componentProperty) && !componentProperty.equals(parentPojo.identifierProperty)>	
			<rich:column>
				<f:facet name="header">
					<ui:include src="layout/sort.xhtml">
						<ui:param name="entityList" value="${'#'}{${componentName}List}"/>
						<ui:param name="propertyLabel" value="${property.name}"/>
						<ui:param name="propertyPath" value="${componentName}.${property.name}"/>
						<ui:param name="tableId" value="${componentName}Table"/>
					</ui:include>
				</f:facet>
				<@outputValue property=parentPojo.identifierProperty expression="${'#'}{${componentName}.${property.name}.${componentProperty.name}}" indent=12/>
			</rich:column>
	   </#if>
	</#foreach>
	</#if>
	</#if>
	</#foreach>
			<f:facet name="footer">
				<rich:datascroller maxPages="5" page="${'#'}{${componentName}List.page}" />
			</f:facet>   
		</rich:dataTable>
	</h:form>
</ui:define>

</ui:composition>
